package com.demo.apparel.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.*;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

@Configuration
public class SwaggerConfig {

    @Bean
    public OpenAPI baseOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("衣合客栈 API")
                        .version("v1.0")
                        .description("衣合客栈 项目接口文档")
                        .contact(new io.swagger.v3.oas.models.info.Contact()
                                .name("唐仲喝")
                                .email("3317877413@qq.com")
                                .url("还没有")
                        ))
                .components(new io.swagger.v3.oas.models.Components()
                        .addSecuritySchemes("BearerAuth", new SecurityScheme()
                                .type(SecurityScheme.Type.HTTP)
                                .scheme("bearer")
                                .bearerFormat("JWT")))
                .addSecurityItem(new SecurityRequirement().addList("BearerAuth"));
    }

    @Bean
    public GroupedOpenApi uniappApi() {
        return GroupedOpenApi.builder()
                .group("微信小程序接口文档")
                .packagesToScan("com.demo.apparel.controller.uniapp")
                .build();
    }

    @Bean
    public GroupedOpenApi webApi() {
        return GroupedOpenApi.builder()
                .group("后台管理接口文档")
                .packagesToScan("com.demo.apparel.controller.web")
                .build();
    }
}
